home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.7z / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / oldgetddr < prev    next >
Encoding:
Text File  |  2006-10-19  |  11.7 KB  |  463 lines

  1. * Function GETDDR - GET Directory Descriptor Record
  2. *
  3. * This function will take the name of the file in the
  4. * FCN (Filename Compare Buffer) and get the DDR of the
  5. * directory the file is named in.  If it is already in
  6. * memory, it will set R5 to point to the DDR.  If it
  7. * is not already in memory, it will read it from the
  8. * disk.  If it cannot read it from the disk for any reason,
  9. * it will return a 0 in R5.
  10. *
  11. * Register Usage:
  12. *   R5  - points to DDR in memory
  13. *   R10 - Flag to indicate if we found the directory we
  14. *         want or a higher level directory
  15. *
  16. * Output:
  17. *   R5 - Points to the ddr in RAM bank 3
  18. *        R5 = 0 if the DDR is not found
  19. *   SAVEAU - contains the AU of the ddr
  20. *
  21.  
  22. GETDDR CLR  R10              Set flag for directory
  23.        ANDI R12,>FF00        Make sure R12 is base CRU address
  24.        AI   R12,24
  25.        LDCR @B04,4           Select RAM bank 4
  26.  
  27.        LI   R2,NCB+40        Search for last period '.'
  28. GDDR2  DEC  R2
  29.        CI   R2,NCB-1         If there are no periods,
  30.        JEQ  GDDR3              then we have to read the VIB
  31.        CB   *R2,@PERIOD
  32.        JNE  GDDR2
  33.  
  34. * Now search all subdirectory names in the cache for a match
  35. *
  36. GDDR3
  37.        BLWP @FDDR
  38.        JEQ  GDDR10
  39.  
  40. * The directory name is not in cache.  We will have to try
  41. * the next higher level directory.
  42. *
  43.        SETO R10
  44.        CI   R2,NCB-1         See if we have to read the VIB
  45.        JNE  GDDR2
  46.  
  47. * OK, we will have to read in the VIB.
  48. *
  49.        CLR  R7               Select sector #0
  50.        CLR  R8
  51.        LDCR @ZERO,4          Select RAM bank 0
  52.        BLWP @BANKIT
  53.        DATA SCSIRD
  54.        JEQ  GDDR4
  55.        AI   R8,16            Try reading the copy
  56.        BLWP @BANKIT
  57.        DATA SCSIRD
  58.        JEQ  GDDR4
  59.        CLR  R5               An error occurred
  60.        RT
  61.  
  62. GDDR4  LDCR @B04,4           Select RAM bank 4
  63.        BLWP @RESDCE          Reserve a Directory Cache Entry
  64.  
  65. * Now R4 points to DCE
  66. *     R5 points to DDR
  67.  
  68. * Set up Directory cache entry
  69. *
  70.        MOVB R6,*R4+          Put in SCSI ID
  71.        MOVB @B03,*R4+        Put in RAM bank of DDR
  72.        MOV  R5,*R4+          Put in DDR address
  73.        AI   R4,40            Blank out the name
  74.        CLR  *R4+             Set AU to 0
  75.        SETO *R4              Set age to -1 so it doesn't get swapped out
  76.  
  77. * Now copy the VIB to the DDR cache
  78. *
  79.  
  80.        LI   R1,SECBUF        SCSI buffer address
  81.        LI   R0,256
  82. GDDR6  LDCR @ZERO,4          Select RAM bank 0
  83.        MOV  *R1+,R2
  84.        LDCR @B03,4           Select RAM bank 3
  85.        MOV  R2,*R5+
  86.        DECT R0
  87.        JNE  GDDR6
  88.  
  89.        AI   R5,-256          Now get the Sectors/AU from the VIB
  90.        MOV  @10(R5),R0       Get disk size
  91.        MOV  @16(R5),R5
  92.        SRL  R5,12
  93.        INC  R5
  94.        LDCR @B04,4           Select RAM bank 4
  95.        MOV  R6,R4
  96.        SRL  R4,8
  97.        SLA  R4,1
  98.        MOV  R5,@SAUTBL(R4)
  99.        MOV  R0,@DSZTBL(R4)
  100.  
  101.        B    @GETDDR          Now try it again
  102.  
  103. ************************************************************
  104. *
  105. * Here is where we have to look at subdirectory names to
  106. * get the next DDR.  Unless of course, we have the DDR we
  107. * want.
  108. *
  109.  
  110. GDDR10 MOV  @44(R4),@SAVEAU
  111.        MOV  @2(R4),R5        See if DDR is in memory
  112.        JNE  GDDR16
  113.  
  114.        MOV  @44(R4),R7       OK, we need to read it into memory
  115.        LI   R3,SECBUF        Pointer to SCSI buffer
  116.        MOV  R6,R5            Get AU of DDR
  117.        SRL  R5,8
  118.        SLA  R5,1
  119.        MPY  @SAUTBL(R5),R7   Multiply AU by Sectors/AU
  120.        SRL  R8,1             Divide by 2
  121.        JNC  GDDR11
  122.        AI   R3,>100          We will use last 256 bytes
  123. GDDR11 SRL  R7,1
  124.        JNC  GDDR12
  125.        AI   R8,>8000
  126. GDDR12 BLWP @BANKIT          Read the DDR from the drive
  127.        DATA SCSIRD
  128.        JEQ  GDDR14
  129.        CLR  R5               Error, return a zero
  130.        RT
  131.  
  132. * Copy the 256 byte sector from the SCSI buffer to the
  133. * DDR cache
  134.  
  135. GDDR14 LDCR @B04,4           Select RAM bank 4
  136.        BLWP @FREDCE
  137.        LI   R1,256
  138. GDDR15 LDCR @ZERO,4          Select RAM bank 0
  139.        MOV  *R3+,R7
  140.        LDCR @B03,4           Select RAM bank 3
  141.        MOV  R7,*R5+
  142.        DECT R1
  143.        JNE  GDDR15
  144.  
  145.        AI   R5,-256          Restore pointer
  146.  
  147. GDDR16 CI   R10,0            See if we are done
  148.        JNE  GDDR17
  149.        LDCR @B04,4           Update age if necessary
  150.        C    @46(R4),@>5FFE
  151.        JH   GDR16A
  152.        JEQ  GDR16A
  153.        INC  @>5FFE
  154.        MOV  @>5FFE,@46(R4)
  155. GDR16A
  156.        RT
  157.  
  158. * Move the directory name to the file name compare buffer in bank 0.
  159. *
  160. GDDR17 INC  R2
  161.        LI   R3,FNCB
  162. GDDR18 LDCR @B04,4           Select RAM bank 4
  163.        CB   *R2,@PERIOD
  164.        JEQ  GDR18A
  165.        MOVB *R2+,R4
  166.        LDCR @ZERO,4          Select RAM bank 0
  167.        MOVB R4,*R3+
  168.        JMP  GDDR18
  169.  
  170. GDR18A LDCR @ZERO,4
  171. GDDR19 CI   R3,FNCB+10       See if we need to pad with spaces
  172.        JEQ  GDDR20
  173.        MOVB @SPACE,*R3+
  174.        JMP  GDDR19
  175.  
  176. * Now start reading directory names
  177. *
  178. * We do a binary search of the subdirectory names in the DDR
  179. *
  180. GDDR20 LDCR @B04,4           Select RAM bank 4
  181.        MOV  R6,R3            Get the number of sectors/AU for this device
  182.        SRL  R3,8
  183.        SLA  R3,1
  184.        MOV  @SAUTBL(R3),R3
  185.  
  186.        LDCR @B03,4           Select RAM bank 3
  187.        CLR  R0               R0 points to lower bound of subdirectories
  188.        MOVB @23(R5),R1       Get the number of subdirectories
  189.        JNE  GDDR21           If this directory has no subdirectories,
  190. GDDERR CLR  R5               then return a null pointer
  191.        RT
  192.  
  193. GDDR21 SRL  R1,8
  194.        DEC  R1
  195.  
  196. GDDR22 LDCR @B03,4           Select RAM bank 3
  197.        MOV  R0,R10           Calculate the midpoint
  198.        A    R1,R10
  199.        ANDI R10,>FFFE
  200.        A    R5,R10
  201.        MOV  @28(R10),R7      Get AU of subdirectory we want to check
  202.        LDCR @B04,4           Select RAM bank 4
  203.        MOV  R7,@SAVEAU       Save the AU to put in the cache entry
  204.        MPY  R3,R7            convert AU to SCSI sector
  205.        LI   R4,SECBUF        R4 points to SCSI buffer
  206.        SRL  R8,1
  207.        JNC  GDDR23
  208.        AI   R4,>0100         Read upper 256 bytes of 512 byte buffer
  209. GDDR23 SRL  R7,1
  210.        JNC  GDDR24
  211.        AI   R8,>8000
  212. GDDR24 LDCR @ZERO,4          Select ram bank 0
  213.        BLWP @BANKIT          Read DDR from SCSI drive
  214.        DATA SCSIRD
  215.        JNE  GDDERR           Branch if there was a read error
  216.  
  217. * Now compare the directory name to the one in the FNCB
  218. *
  219.        LI   R7,FNCB
  220.        LI   R9,10
  221. GDDR25 C    *R4+,*R7+
  222.        JH   GDDR28
  223.        JL   GDDR29
  224.        DECT R9
  225.        JNE  GDDR25
  226.  
  227. * We have a match - reserve a DCE and copy the DDR
  228. *
  229.        AI   R4,-10           Restore pointer to DDR in SCSI buffer
  230.        MOV  R4,R7            Save pointer
  231.        LDCR @B04,4           Select RAM bank 4
  232.        BLWP @RESDCE
  233.  
  234. * Now fill in the Directory Name Cache Entry
  235. *
  236.        MOVB R6,*R4+          Store SCSI ID
  237.        MOVB @B03,*R4+        Put in RAM bank of the DDR
  238.        MOV  R5,*R4+          Put in the DDR address
  239.  
  240. * Now fill in the name of the directory
  241. *
  242.        MOV  R4,R3
  243.        LI   R1,NCB
  244. GDDR26 MOVB *R1+,*R3+
  245.        C    R1,R2
  246.        JNE  GDDR26
  247.  
  248. * Put in the AU
  249. *
  250.        MOV  @SAVEAU,@40(R4)
  251.  
  252. * And finally put in the age to complete the entry
  253. *
  254.        INC  @>5FFE
  255.        MOV  @>5FFE,@42(R4)
  256.  
  257. * Now copy the DDR
  258. *
  259.        LI   R1,256
  260. GDDR27 LDCR @ZERO,4          Select RAM bank 0
  261.        MOV  *R7+,R8
  262.        LDCR @B03,4           Select RAM bank 3
  263.        MOV  R8,*R5+
  264.        DECT R1
  265.        JNE  GDDR27
  266.  
  267. * Now since we've destroyed R5 and R10, just go back to
  268. * the beginning of the subroutine.  We'll find this
  269. * directory in cache, so it shouldn't take very long.
  270. *
  271.        B    @GETDDR
  272.  
  273.  
  274. * If the names didn't match, select another directory name
  275. * to search.  If there are none left, return a null pointer.
  276. *
  277. GDDR28 C    R0,R1
  278.        JEQ  GDDERR
  279.        MOV  R0,R10
  280.        A    R1,R10
  281.        SRL  R10,1
  282.        C    R10,R0
  283.        JEQ  GDDERR
  284.        MOV  R10,R1
  285.        DEC  R1
  286.        JMP  GDDR22
  287.  
  288. GDDR29 C    R0,R1
  289.        JEQ  GDDERR
  290.        MOV  R0,R10
  291.        A    R1,R10
  292.        SRL  R10,1
  293.        MOV  R10,R0
  294.        INC  R0
  295.        JMP  GDDR22
  296.  
  297.  
  298. ************************************************************
  299. *
  300. * Function GETFDR
  301. *
  302. * This function will try to get the File Descriptor Record
  303. * of the file specified in the name compare buffer.  If it
  304. * is successful, it will copy the FDR into the SCSI buffer
  305. * and return a pointer to it.
  306. *
  307. * Output:
  308. *    R5 points to FDR in RAM bank 0 if found
  309. *       R5 = 0 if FDR not found
  310. *    SAVEAU contains the AU of the FDR on disk
  311. *
  312. **********************************************************
  313.  
  314. GETFDR ANDI R12,>FF00
  315.        AI   R12,24
  316.        LDCR @B02,4       Select RAM bank 2
  317.        MOV  R11,@GFDRRT  Save return address
  318.  
  319.        BL   @GETDDR      Get the DDR first
  320.  
  321.        CI   R5,0
  322.        JEQ  GFDR98
  323.  
  324. * Check to make sure the number of files in the directory
  325. * does not equal zero.
  326.  
  327.        LDCR @B03,4       Select RAM bank 3
  328.        MOVB @22(R5),R1   Get the number of files
  329.        JEQ  GFDR98
  330.  
  331. * Read the file index and store it in DFDR
  332. *
  333.        MOV  @24(R5),R7   Get AU of the file index
  334.        LDCR @B04,4
  335.        MOV  R6,R3
  336.        SRL  R3,8
  337.        SLA  R3,1
  338.        MPY  @SAUTBL(R3),R7
  339.  
  340.        LI   R5,SECBUF    Point to SCSI buffer
  341.        SRL  R8,1
  342.        JNC  GFDR1
  343.        AI   R5,>100
  344. GFDR1  SRL  R7,1
  345.        JNC  GFDR2
  346.        AI   R8,>8000
  347. GFDR2  LDCR @ZERO,4
  348.        BLWP @BANKIT      Read the index from disk
  349.        DATA SCSIRD
  350.        JNE  GFDR98
  351.  
  352. * Copy the filename to the filename compare buffer (FNCB)
  353. *
  354.        LDCR @B02,4       Select RAM bank 2
  355.        LI   R2,NCB+39
  356. GFDR3  CB   *R2,@PERIOD
  357.        JEQ  GFDR4
  358.        DEC  R2
  359.        CI   R2,NCB-1
  360.        JNE  GFDR3
  361.  
  362. GFDR4  INC  R2
  363.        LI   R4,FNCB
  364. GFDR5  CI   R2,NCB+40
  365.        JEQ  GFDR6
  366.        CB   *R2,@SPACE
  367.        JEQ  GFDR6
  368.        MOVB *R2+,R3
  369.        LDCR @ZERO,4
  370.        MOVB R3,*R4+
  371.        LDCR @B02,4
  372.        JMP  GFDR5
  373.  
  374. GFDR6  LDCR @ZERO,4      Pad the rest of the name with spaces
  375. GFDR6A CI   R4,FNCB+10
  376.        JEQ  GFDR7
  377.        MOVB @SPACE,*R4+
  378.        JMP  GFDR6A
  379.  
  380. * Here is where we return to the calling program
  381. *
  382. GFDR98 CLR  R5           We did not find the FDR
  383. GFDR99 LDCR @B02,4       Select RAM bank 2
  384.        MOV  @GFDRRT,R11  Get our return address
  385.        RT
  386.  
  387. GFDR7
  388.  
  389. * set the bounds for our binary search
  390. *
  391.        SRL  R1,8
  392.        CLR  R0
  393.  
  394. * Copy the file index from the SCSI buffer to DFDR
  395. *
  396.        LI   R2,DFDR
  397.        MOV  R1,R3
  398.        DEC  R1
  399. GFDR8  LDCR @ZERO,4
  400.        MOV  *R5+,R4
  401.        LDCR @B02,4
  402.        MOV  R4,*R2+
  403.        DEC  R3
  404.        JNE  GFDR8
  405.  
  406. GFDR9  LDCR @B02,4
  407.        MOV  R0,R2        Calculate the midpoint for the
  408.        A    R1,R2        binary search
  409.        ANDI R2,>FFFE
  410.        MOV  @DFDR(R2),R7 Get AU of FDR we want to check
  411.        LDCR @B04,4       Select RAM bank 4
  412.        MOV  R7,@SAVEAU   Save the AU in case this is the one
  413.        MOV  R6,R3
  414.        SRL  R3,8
  415.        SLA  R3,1
  416.        MPY  @SAUTBL(R3),R7
  417.        LDCR @ZERO,4
  418.        LI   R5,SECBUF
  419.        SRL  R8,1
  420.        JNC  GFDR10
  421.        AI   R5,>100
  422. GFDR10 SRL  R7,1
  423.        JNC  GFDR11
  424.        AI   R8,>8000
  425. GFDR11 BLWP @BANKIT      Read the FDR from disk
  426.        DATA SCSIRD
  427.        JNE  GFDR98
  428.  
  429. * Now compare the filename
  430. *
  431.        LI   R3,FNCB
  432. GFDR12 C    *R5+,*R3+
  433.        JL   GFDR13
  434.        JH   GFDR14
  435.        CI   R3,FNCB+10
  436.        JNE  GFDR12
  437.  
  438.        AI   R5,-10       We found it!!!
  439.        JMP  GFDR99
  440.  
  441. * The file name did not match.  Modify the bounds
  442. * of our binary search
  443. *
  444. GFDR13 C    R0,R1        Is there anything left to check?
  445.        JEQ  GFDR98       If not, error
  446.        MOV  R0,R2        Recompute the midpoint
  447.        A    R1,R2
  448.        SRL  R2,1
  449.        MOV  R2,R0        Modify lower bound of the search
  450.        INC  R0
  451.        JMP  GFDR9
  452.  
  453. GFDR14 C    R0,R1        Is there anything left to check?
  454.        JEQ  GFDR98       If not, error
  455.        MOV  R0,R2        Recompute the midpoint
  456.        A    R1,R2
  457.        SRL  R2,1
  458.        C    R2,R0
  459.        JEQ  GFDR98
  460.        MOV  R2,R1        Modify the upper bound of the search
  461.        DEC  R1
  462.        JMP  GFDR9
  463.